<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
    String path = request.getContextPath();
			String basePath = request.getScheme() + "://"
					+ request.getServerName() + ":" + request.getServerPort()
					+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>" />

		<title>预算列表</title>

		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta http-equiv="expires" content="0" />
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
		<meta http-equiv="description" content="This is my page" />
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/css/common.css" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/css/tag.css" />
		<link rel="stylesheet" type="text/css" 
			href="<%=path%>/js/jquery-ui-1.8.21.custom/css/smoothness/jquery-ui-1.8.21.custom.css" />
		<script type="text/javascript" src="<%=path%>/js/jquery-1.7.2.js"></script>
		<script type="text/javascript"
			src="<%=path%>/js/jquery-ui-1.8.21.custom/js/jquery-ui-1.8.21.custom.min.js"></script>
		<script type="text/javascript">
			$(function(){
				$("#modifyBudgetDialog").dialog({
					autoOpen: false,
					modal: true,
					width: 400,
					height: 300,
					title: "预算编辑",
					resizable: false,
					show: "blind",
					hide:"slide",
					buttons: {
				      "确定": function(){
				      	var modify_budget = $("#modify_budget").val();
				      	var reg1 = /^\d*?$/;
				      	var reg2 = /^\d+\.\d{1,3}$/;
				      	if(modify_budget.length <= 12){
				      		if(reg1.test(modify_budget) || reg2.test(modify_budget)){
								$("#form1").submit();
							}else{
								alert("预算值格式错误！");
							}
				      	}else{
				      		alert("预算值总长度大于12！");
				      	}
				      },
				      "取消": function(){
				      	$(this).dialog("close");
				      }
				   }
				});
				//
				$("a[class^='modifyButton_']").click(function(){
					var id = $(this).attr("class").split("_")[1];
					$("#modify_id").val(id);
					$("#modify_type").val($(this).prev().val());
					$("#modify_subType").val($(this).parent().prev().prev().text());
					$("#modify_budget").val($(this).prev().prev().val().replace(/\,/g, ""));
					//显示弹框
					$("#modifyBudgetDialog").dialog("open");
				});
				//
		        //selectNav('nav7');
		        //
		        $("#year").change(function(){
		        	var year = $(this).val();
		        	if(year != ""){
		        		window.location.href = "budgetList.action?fbParam.year=" + year;
		        	}
				});
		    });
		</script>
	</head>

	<body>
		<!-- 顶栏start -->
		<jsp:include page="/jsp/common/top.jsp"></jsp:include> 
		<!-- 顶栏end -->
	
		<!-- 顶部start -->
		<div id="main">
			<div class="body">
				<!-- 导航菜单 -->
				<jsp:include page="../common/nav.jsp"></jsp:include>
				<!-- 主体 -->
				<div class="main_body">
					<table class="condition bg1"
						style="width: 100%; font-size: 14px; font-weight: bold; color: #000000;"
						align="center">
						<tr>
							<td width="34%" style="height: 40px;">
								&nbsp;&nbsp;&nbsp;&nbsp;
						        <label>年度：</label> 
                       	        &nbsp;&nbsp;
                       	        <s:select id="year" list="years" value="fbParam.year"></s:select>
							</td>
							<td  style="height: 40px; text-align: left;">
							</td>
							<td width="55%" style="height: 40px; text-align: right;">
								<input type="button" class="btn-title" value="预算导入"
									onclick="window.location.href='toUploadSourcePlanAction.action'" />
								&nbsp;&nbsp;
								<input type="button" class="btn-title" value="预算录入"
									onclick="window.location.href='mediaPlanCountAdd.action'" />
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							</td>
						</tr>
					</table>

					<div id="list_div">
						<s:if test="null != costTypeBudgets && costTypeBudgets.size > 0">
						<table class="table_list" style="width: 100%;">
							<tr class="bg">
								<th>
									类别
								</th>
								<th>
									子类
								</th>
								<th>
									预算值
								</th>
								<th>
									操作
								</th>
							</tr>
							<s:iterator value="costTypeBudgets">
								<s:iterator status="st" value="costSubTypeBudgets">
									<tr>
									<s:if test="#st.index == 0">
										<td rowspan="${costSubTypeBudgetsSize }">${costTypeName }&nbsp;</td>
									</s:if>
									<td>${costSubTypeName }&nbsp;</td>
									<td><fmt:formatNumber value="${budget}"></fmt:formatNumber></td>
									<td>
										<input type="hidden" value="<fmt:formatNumber value="${budget}"></fmt:formatNumber>"/>
										<input type="hidden" value="${costTypeName }"/>
										<s:if test="type == 1">
											<a class="modifyButton_${id }" title="编辑" style="cursor: pointer;">
												<img src="images/modify.gif" alt="编辑" />
											</a>
										</s:if>
										<s:elseif test="type == 2">
											<a href="mediaBudgetList.action?sourcePlanYear.planYear=${year }&sourcePlanYear.city=${city }&sourcePlanYear.costType=${costType }&sourcePlanYear.costSubtype=${costSubType }" title="详情">
												<img src="images/detail.gif" alt="详情" />
											</a>
										</s:elseif>
										<s:elseif test="type == 11">
											<a href="javascript:alert('初始化数据不可编辑！');" title="编辑">
												<img src="images/modify.gif" alt="编辑" />
											</a>
										</s:elseif>
										<s:elseif test="type == 22">
											<a href="javascript:alert('初始化数据不可查看详情！');" title="详情">
												<img src="images/detail.gif" alt="详情" />
											</a>
										</s:elseif>
										&nbsp;
									</td> 
									</tr>
								</s:iterator>
							</s:iterator>
						</table>
						</s:if>
						<s:else>
							<table align="left" style="font-size:13px; font-weight: bold;">
								<tr>
									<td>
										暂无相关数据！
									</td>
								</tr>
							</table>
						</s:else>
					</div>
				</div>
			</div>
		</div>
		<!-- 顶部end -->
		
		<!-- 底部start -->
		<jsp:include page="/jsp/common/bottom.jsp"></jsp:include> 
		<!-- 底部end -->
		<div id="modifyBudgetDialog">
			<form id="form1" action="modifyBudget.action" method="post">
			<table style="width:100%;">
				<tr>
					<th>类别：</th>
					<td>
						<input id="modify_type" type="text" class="text" style="width:225px;" disabled="disabled" />
					</td>
				</tr>
				<tr>
					<th>子类：</th>
					<td>
						<input id="modify_subType" type="text" class="text" style="width:225px;" disabled="disabled" />
					</td>
				</tr>
				<tr>
					<th style="">预算值：</th>
					<td style="">
						<input id="modify_budget" name="fbParam.sBudget" type="text" class="text" style="width:225px;" />
						<input id="modify_id" name="fbParam.fundbudgetId" type="hidden" />
					</td>
				</tr>
			</table>
			</form>
		</div>
	</body>
</html>
